package com.coder520.common.untils;

import java.util.Calendar;
import java.util.Date;


public class DateUtils {

    private static Calendar calendar = Calendar.getInstance();

    //得到星期几的值
    public static int getweek(){

        calendar.setTime(new Date());
        int week = calendar.get(Calendar.DAY_OF_WEEK)-1;
        if(week<0) week=7;
        return week;
    }

    //得到打卡时间差
    public static int getMinuite(Date statrDate,Date endDate){
        //转化成毫秒
        Long startTime = statrDate.getTime();
        Long endTime = endDate.getTime();
        //相减再转化成分
        int minute = (int) ((endTime-startTime)/(1000*60));
        return minute;
    }

    //设置当天某个时间为上下午打卡结点
    public static Date getdate(int hour,int minute){

        calendar.set(Calendar.HOUR_OF_DAY,hour);
        calendar.set(Calendar.MINUTE,minute);
        return calendar.getTime();
    }

}
